# coding=utf-8
# Author: huxin
# Time : 2020/9/17:15:08
import redis
import json


class Redis:

    def get_connect(self):
        #r = redis.Redis(host='119.3.37.131', port=6379, db=12, password='wPg@2019Test&*(')
        r = redis.Redis(host='10.10.102.90', port=6379, db=0, password='wPg@2019Test*(')
       # r = redis.Redis(host='10.10.102.74', port=6379, db=0, password='wpgredis')
        return r

    @staticmethod
    def get_value(name,key) -> dict:
        """
        name:redis中的HASH
        key:HASH下面的key值
        """
        r = Redis().get_connect()
        value = r.hget(name,key)
        value = json.loads(value)
        return value


    @staticmethod
    def set_value(name,key,map):
        """
        name:redis的hash
        key:key
        map:value字典类型
        """
        r = Redis().get_connect()
        r.hset(name,key, map)


